﻿<%@ WebHandler Language="C#" Class="regAjax" %>
using System;
using System.Web;
public class regAjax : IHttpHandler {
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        string username = context.Request.QueryString["name"].ToString();
        string ret = "";  //ret=1用户名存在。0用户不存在，可以添加  2:成功写入到数据库，3写数据库失败
        NVR.BLL.UserInfo user = new NVR.BLL.UserInfo();
        NVR.Entity.userInfo userInfo = new NVR.Entity.userInfo();
        string pwd = "", email = "", qq = "", tel = "";
        if (context.Request.QueryString["pwd"] != null)
        {
            pwd = context.Request.QueryString["pwd"].ToString();
            email = context.Request.QueryString["email"].ToString();
            qq = context.Request.QueryString["qq"].ToString();
            tel = context.Request.QueryString["tel"].ToString();
            userInfo.username = username;
            userInfo.pwd = pwd;
            userInfo.email = email;
            userInfo.tel = tel;
            userInfo.qq = qq;
            userInfo.regDate = DateTime.Now;
            userInfo.purview = 2;
            userInfo.parentid = 0;
            if (user.添加(userInfo) == 1)
            {
                ret = "2";  //成功存储用户名
            }
            else
            {
                ret = "3";
            }
        }
        else
        {
            userInfo = user.GetUserInfo(username);
            if (userInfo != null)
            {
                ret = "1";
            }
            else
            {
                ret = "0";
            }
        }
        context.Response.Write(ret);
    }
    public bool IsReusable {
        get {
            return false;
        }
    }

}